package com.fz.controller;

import com.fz.service.TUserService;
import com.fz.service.UserRoleService;
import com.fz.vo.ResultVo;
import com.fz.vo.RoleUserVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 关联表 前端控制器
 * </p>
 *
 * @author wangyi
 * @since 2024-08-20
 */
@RestController
@RequestMapping("/userRole")
public class UserRoleController {
    @Resource
    TUserService userService;
    @Resource
    UserRoleService userRoleService;
    @GetMapping("/getUser")
    ResultVo<RoleUserVO> getUserList(Long roleId){
        return ResultVo.success(new RoleUserVO(userService.getList(),userRoleService.getByRoleId(roleId)));
    }
    @PostMapping("/save")
    ResultVo<Boolean> save(Long roleId, Long[] userIds){
        return ResultVo.success(userRoleService.save(roleId,userIds));
    }
}
